﻿using Microsoft.Extensions.DependencyInjection;
using Modules.Project.Repositories;
using PmSoft;

namespace Modules.Project;

[UseDI(ServiceLifetime.Scoped)]
public class ProjectPositionService
{
    private readonly ProjectPositionRepository projectPositionRepository;

    public ProjectPositionService(ProjectPositionRepository projectPositionRepository)
    {
        this.projectPositionRepository = projectPositionRepository;
    }

    public IEnumerable<ProjectPosition> GetProjectPositionByProjectId(int projectId)
    {
        return projectPositionRepository.GetProjectPositionByProjectId(projectId);
    }

    public IEnumerable<ProjectPosition> GetProjectPositionByProjectIds(IEnumerable<int> projectIds)
    {
        return projectPositionRepository.GetProjectPositionByProjectIds(projectIds);
    }

    public void Create(ProjectPosition projectPosition)
    {
        projectPositionRepository.Insert(projectPosition);
    }

    public void Update(ProjectPosition projectPosition)
    {
        projectPositionRepository.Update(projectPosition);
    }

    public void Delete(int id)
    {
        projectPositionRepository.DeleteByEntityId(id);
    }

    public void Deleted(IEnumerable<int> ids)
    {
        foreach (var id in ids)
        {
            Delete(id);
        }
    }
}